home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / SPEZIAL / GEMVIEW / UTILITY / GEM_VIEW.101 / VIEW_101.ENG < prev   
Encoding:
Text File  |  1993-09-14  |  14.8 KB  |  431 lines

  1. view.txt V1.01, 19.08.1993
  2.  
  3.       The 'View'-protocol
  4.     =======================
  5.  
  6. This is now version 1.01 of view.txt. Julian Reschke had the 
  7. brilliant idea, that a 'View' environment variable would be much 
  8. better than the cookie, we used before.
  9.  
  10.  
  11. The aim of the 'View'-protocol is that all (GEM-)applications can 
  12. easily display files using a 'viewer' and needn't implement 
  13. view-functions for various formats themselves.
  14.  
  15. As there are already several view-applications, as GEM-View 
  16. (from Dieter Fiebelkorn) or 1st-View/1st-Guide (from Guido 
  17. Vollbeding), some applications already have options to use these 
  18. programs (if installed as an accessory) to view files.
  19.  
  20. This is why Dieter and I have developed the 'View'-protocol, 
  21. that there is an uniform interface to the different viewers, so 
  22. every application is able to use installed view-accessories, 
  23. even if it doesn't know and support it explicitly.
  24.  
  25. This version of the 'View'-protocol is experimentally 
  26. implemented in GEM-View and ShowImage (my very own viewer).
  27.  
  28. ALL PROGRAMMERS ARE STRONGLY EXPECTED TO USE AND EXPERIMENT 
  29. WITH THIS PROTOCOL!
  30. So we hope that sometime it becomes a standard for viewers and 
  31. programs that use it.
  32.  
  33. I would *REALLY* like to get any kind of reaction, that I know, 
  34. if someone else uses this protocol and it should be developed 
  35. further.
  36. So please contact me:
  37.  
  38. Peter Seitz, Robert-Koch-Str.6, 63225 Langen, GERMANY
  39. E-Mail (Internet): seitz@rbg.informatik.th-darmstadt.de
  40.  
  41. The 'View'-protocol is based on parts of the XAcc-protocol, so 
  42. one should get a copy of it's documentation (file xacc_mt.txt).
  43.  
  44.  
  45. This protocol should be quite easy to implement by both the 
  46. writers of viewers and of all other applications and should be 
  47. of a big advantage for the user, as he can use his favourite 
  48. viewer with all applications.
  49.  
  50. Peter
  51.  
  52.  
  53. In the following, 'viewer' refers to the accessory or 
  54. application that is used to display the file(s); 'application' 
  55. means always a program, that wants to use the 'viewer'.
  56.  
  57.  
  58.  
  59. 1. WHO is the viewer???
  60. =======================
  61.  
  62. * First the application should check, if there is a viewer, the 
  63. user prefers. Therefore it should see, if there is
  64.  a) an environment variable named 'View' (the case is 
  65.     significant!).
  66.  b) a cookie named 'View' (the case is here significant, too).
  67.  c) the 'SHSHOW' environmenr variable (which is also used by the 
  68.     MTOS' desktop).
  69.  
  70. The value of each one of these variables is a pointer to the 
  71. full pathname of the viewer.
  72. Using appl_find() one can see, if one of them is already loaded 
  73. (as an ACC or, with a multi-tasking-system, also as an APP).
  74. To use appl_find, the path and the extension have to be removed 
  75. from the name, and the name has to be filled up with spaces to 8 
  76. characters - otherwise appl_find() won't find anything at all...
  77. It should be noted, that appl_find is case sensitive - so 
  78. normally the value MUST be all upper case. It wouldn't be wise 
  79. to convert the name to upper case, as case sensitive file 
  80. systems may be used (eg under MiNT).
  81.  
  82. If the viewer has not yet sent it's XAcc-identification (ACC_ID-
  83. message), the application does this now. This may be the case, 
  84. if the main-application doesn't support the XAcc-protocol.
  85.  
  86. * If no viewer could be found, the application should check all 
  87. APPs/ACCs that have sent their XAcc-identification:
  88. If the extended name (introduced in version 2 of the XAcc-
  89. protocol) contains a string of the form '2View' (this is the 
  90. application type 'viewer') or 'NView' (the generic type 'viewer' 
  91. - whatever this means), this is a program that supports the 
  92. 'View'-protocol and may be used as a viewer.
  93. Please notice, that the case of 'View' here is significant, too.
  94.  
  95. * If the application really can't find a viewer, it can at last 
  96. try to load the viewer itself, if one of the variables / the 
  97. cookie was found, using the full pathname (given as the value of 
  98. the variable / cookie).
  99. If the 'View' variable / cookie is used, the viewer may be 
  100. started as an ACC as well; this is possible if Chameleon or MTOS 
  101. is present.
  102. As a consequence the viewer given in the 'View' variable / 
  103. cookie *MUST* be able to run both as an APP and ACC!
  104. If the viewer can't be used as an ACC, the SHSHOW variable have 
  105. to be used instead.
  106.  
  107.  
  108. Normally, one should use one of the enironment variables 'View' 
  109. or 'SHSHOW'. These should be placed in the desktop's 
  110. environment, as all applications started by the desktop will 
  111. inherit its environment. This can be done by special programms 
  112. or if one uses MiNT, it is much easier: just place a line like
  113.     setenv View C:\GEM_VIEW\GEMVIEW.APP
  114. and/or
  115.     setenv SHSHOW C:\GEM_VIEW\GEMSHOW.PRG
  116. in your mint.cnf file.
  117.  
  118. The cookie should normally not be used anymore.
  119.  
  120.  
  121.  
  122. 2. WHAT kind of files can be displayed?
  123. =======================================
  124.  
  125. The (XAcc-)extended name of the viewer should contain an entry 
  126. of the form 'X.ext' for every supported file-formats, where 
  127. 'ext' may be one of the following:
  128.  
  129. X.ART    - Art-Director
  130. X.ASC    - prargraphs end with CR, lines may end with LF
  131. X.B&W    - Imagelab Images
  132. X.BLK    - GFA-Bit-Block (3 words header: width-1 / height-1 /
  133.         planes)
  134. X.BMP    - OS/2 Bitmap, MS-Window Bitmaps
  135. X.CFN    - Calamus Font
  136. X.CRG    - Calamus Raster
  137. X.CTX    - Calamus Text
  138. X.CVG    - Calamus Vektor
  139. X.DOC    - 1stWord Docs
  140. X.DOO    - Doodle Mono
  141. X.ESM    - Enhanced Simplex
  142. X.FNT    - GDOS - Fonts (and nothing else!!)
  143. X.GEM    - GEM-Metafile
  144. X.GIF    - GIF Images
  145. X.GVW    - Used by GEM-View internally and should *NOT* be in this 
  146.         list!!!
  147. X.HEX    - Hex-Dump, this means that the viewer may show dumps.
  148. X.IFF    - IFF-File in general!
  149. X.IFF.ILBM - IFF InterLeavedBitMaps.
  150. X.IFF.type - other IFF-file types.
  151. X.IMC    - Signum!2 Images
  152. X.IMG    - GEM-Images, XIMG
  153. X.JPG    - JPEG Images
  154. X.MAC    - MacPaint Images
  155. X.NEO    - Neochrome Images
  156. X.OUT - The GEM 'OUT'-file (see v_alpha_text)
  157. X.PAC    - STAD Images
  158. X.PC[123]    - Degas compressed Images
  159. X.PCX    - PC Paintbrush
  160. X.P[BGP]M    - Portable Bit Map
  161. X.PIC    - Screen-Dump (the current resolution)
  162. X.PI[123]    - Degas uncompressed Images
  163. X.RLE    - MS-Window Bitmaps
  164. X.RSC    - GEM Resource Files
  165. X.SNP    - Becker Snap Shot (3 words header: width/height/planes)
  166. X.SP[CU]    - Spectrum 512
  167. X.SUN    - Sun Rasterfiles
  168. X.TGA    - Targa Images
  169. X.TIF    - TIFF Images
  170. X.TN[123Y]    - Tiny Images
  171. X.TXT    - ASCII-Text (lines end with CR/LF, it would be nice, if 
  172.         a single LF (unix) or single CR (Mac) would be accepted 
  173.         as a line end, too.)
  174. X.XBM    - X Bitmap File
  175.  
  176. Note: [abc] means one of the characters 'a', 'b' or 'c' and not 
  177.       the string '[abc]'.
  178.  
  179. All other entries starting with 'X.' are reserved for future 
  180. versions!!
  181. If one want to add other formats, please contact me! It would be 
  182. wise, if the entries are unique.
  183.  
  184. I recommend the support of X.IMG, X.GEM and X.OUT, as these are 
  185. the standard formats for GEM-data-exchange!
  186.  
  187. It should be noted, that all the file formats listed here, could 
  188. be a hint which formats are understood, if the Drag & Drop - 
  189. protocol is supported - at least the extensions used there 
  190. should *really* be the same (well, it would be nice...).
  191.  
  192.  
  193.  
  194. 3. HOW can I tell the viewer (what is to be shown)?
  195. ===================================================
  196.  
  197. * Because of the XAcc2-protocol the application knows, which 
  198. message-groups are supported and these messages may be used, if 
  199. the application has the data already in memory (and not within a 
  200. file).
  201.  
  202. * Use the VIEW_xxx-messages, discussed in (5) below. With these 
  203. messages the application has the best control of what's 
  204. happening.
  205. These messages may be used, "if and *ONLY* if" the strings 
  206. '2View' or 'NView' are found in the viewer's extended XAcc-name, 
  207. but this should be normaly the case.
  208. This may be a problem, if the viewer has been started by the 
  209. application. In this case I would suggest to try to send the 
  210. messages and see what's happening - if the viewer doesn't 
  211. support them no reaction is given (as unknown messages should 
  212. be ignored!), otherwise the viewer will send a response.
  213.  
  214. * The viewer is *strongly* suggested to support the VA_START-
  215. message! Of cause this has to be tested in its protostatus (if 
  216. possible, see above).
  217.  
  218. * There is NO explicit support of the Drag & Drop - protocol, as 
  219. this is MiNT-specific, but programs running under MiNT should 
  220. understand this protocol!
  221.  
  222. * All other protocols of cause may be used to inform the viewer 
  223. as well, if they give the possibility to check, if they are 
  224. supported.
  225.  
  226.  
  227. PLEASE keep in mind, that pointers to strings in messages have 
  228. to point to global-readable memory (if running in an environment 
  229. with memory protection)!
  230.  
  231.  
  232.  
  233. 4. WHAT does the viewer do?
  234. ===========================
  235.  
  236. * On startup the viewer should check its parameters, and load 
  237. all files given there. He should look for the ARGV-environment-
  238. variable, too.
  239.  
  240. * The messages of the XAcc-protocol are answered as usual (with 
  241. ACC_ACK).
  242.  
  243. By the way: To send data using the XAcc-messages, I would 
  244. suggest Alt-X as key-combination.
  245.  
  246. * Receiving VA_START the viewer itself has to find out the 
  247. file's type and if he is able to display it.
  248. No reply is given reporting about success or failure!
  249. (If reply is needed, use VIEW_FILE!)
  250.  
  251.  
  252.  
  253. 5. The VIEW_xxx-messages
  254. ========================
  255.  
  256. This is now the description of the 'View'-protocol's own 
  257. messages. In difference to VA_START and XAcc one has more 
  258. possibilities to control, what happens with the viewed file.
  259.  
  260. Please remember, that these messages may be used, "if and *ONLY* 
  261. if" the strings '2View' or 'NView' are found in the viewer's 
  262. extended XAcc-name, as mentioned above.
  263.  
  264.  
  265. In general there are four messages: VIEW_FILE, which may be 
  266. sent to the viewer, and VIEW_FAILED, VIEW_OPEN and VIEW_CLOSED 
  267. that are used to inform the application of what has happened to 
  268. its file.
  269.  
  270. The viewer is expected to answer *EVERY* VIEW_FILE-message he 
  271. recieves, at least with a VIEW_FAILED(VIEWERR_ERROR) (see 
  272. below!).
  273. However, if the viewer doesn't answer and the application needs 
  274. one, it should not hang (of cause :-), but use a timeout (about 
  275. 10 seconds should be enough).
  276.  
  277. It is possible, that the viewer sends some other messages (eg 
  278. AV_ACCWINDOPEN) before answering the VIEW_FILE-message!
  279.  
  280.  
  281. a) view a file
  282.  
  283. The 'VIEW_FILE' message is used by the application to inform 
  284. the viewer, that a file is to be displayed.
  285.  
  286.     msg[0]   = VIEW_FILE
  287.     msg[3/4] = filename // must be global-readable (MiNT's 
  288.                            memory protection)!
  289.     msg[5/6] = 0        // reserved!
  290.     msg[7]   = 0        // zero = new file, see below!
  291.  
  292. This message is (always!) answered by the viewer:
  293.  
  294. - if the file couldn't be displayed with VIEW_FAILED:
  295.     retmsg[0]   = VIEW_FAILED
  296.     retmsg[3/4] = msg[3/4]    // filename (same pointer!)
  297.     retmsg[5]   = errcode    // see below
  298.     retmsg[6]   = 0            // reserved!
  299.     retmsg[7]   = msg[7]    // 0 or >wid<
  300.  
  301.     The >errcode< may be a GEMDOS-error-code (< 0) or one of the 
  302.     following:
  303.         VIEWERR_ERROR    - unspecified error
  304.         VIEWERR_SIZE     - wrong size, eg too big
  305.         VIEWERR_COLOR    - unsupported resolution/color
  306.         VIEWERR_WID      - wrong >wid< (see below)
  307.     It is expected that the viewer informs the users about the 
  308.     error (ie print an message/alertbox), as it knows better what 
  309.     was wrong.
  310.  
  311. - if the file has been displayed, but NO further communication 
  312.   is possible, the viewer sends VIEW_OPEN
  313.     retmsg[0]   = VIEW_OPEN
  314.     retmsg[3/4] = msg[3/4]    // filename
  315.     retmsg[5]   = viewprot_version    // currently 0
  316.     retmsg[6]   = 0        // reserved!
  317.     retmsg[7]   = 0        // 0 = no further communication!
  318.  
  319. - if the file has been displayed AND further communication is 
  320.   possible, the viewer sends VIEW_OPEN
  321.     retmsg[0]   = VIEW_OPEN
  322.     retmsg[3/4] = msg[3/4]    // filename
  323.     retmsg[5]   = viewprot_version    // currently 0
  324.     retmsg[6]   = 0        // reserved!
  325.     retmsg[7]   = wid        // not zero!
  326.  
  327. The >wid< refers to the AES' window-id of the window the file is 
  328. displayed in. This seems to be a unique number representing the 
  329. file, which is used in the further communication as an 
  330. identifier.
  331.  
  332. The currently defined >viewprot_version< is 0.
  333.  
  334.  
  335. b) further communication
  336.  
  337. Once a file is displayed (in a window) and the viewer has 
  338. returned a non-zero wid in msg[7], both the application and the 
  339. viewer may send each other messages refering to this file / 
  340. window.
  341.  
  342. msg[7] will ALWAYS contain the (non-zero) wid as an identifier! 
  343. As this is (supposed to be) unique, msg[3/4] should NOT be 
  344. regarded to identify the file (if msg[7] is not zero), as 
  345. msg[3/4] may be changed.
  346.  
  347. If the viewer receives a wrong wid, he replies by sending a 
  348. VIEW_FAILED-message:
  349.     retmsg[0]   = VIEW_FAILED
  350.     retmsg[3/4] = msg[3/4]
  351.     retmsg[5]   = VIEWERR_WID
  352.     retmsg[6]   = 0
  353.     retmsg[7]   = msg[7]    // the wrong wid
  354.  
  355. The application receiving this message must NOT use this wid 
  356. again, as it might have happened, that the viewer missed to 
  357. send VIEW_CLOSED(wid).
  358.  
  359.  
  360. The application now has the following possibilities to control 
  361. the window:
  362.  
  363.     * The window should be closed (and the file's memory freed):
  364.         msg[0]   = VIEW_FILE
  365.         msg[3/4] = NULL    // remove file
  366.         msg[5/6] = 0
  367.         msg[7]   = wid        // makes only sense, if not zero!
  368.  
  369.     * If the application gets somehow to know, that the 
  370.       displayed file has changed (or another file should be 
  371.       displayed in the same window):
  372.  
  373.         msg[0]   = VIEW_FILE
  374.         msg[3/4] = filename    // may be different
  375.         msg[5/6] = 0
  376.         msg[7]   = wid        // the window's id
  377.  
  378.  
  379. On the other side, the viewer should inform the application of 
  380. what's happening to its file:
  381.  
  382.     * If the window is closed (eg the user closed it or the 
  383.       viewer received AC_CLOSE or VIEW_FILE(NULL, wid)):
  384.  
  385.         msg[0]   = VIEW_CLOSED
  386.         msg[3/4] = filename    // may be NULL and should be ignored!
  387.         msg[5/6] = 0
  388.         msg[7]   = wid
  389.  
  390.       The >filename< should be the one from the VIEW_FILE-
  391.       message, otherwise it may be NULL, as no new global memory 
  392.       should to be allocated.
  393.       If the window was closed due to an error, VIEW_FAILED may 
  394.       be sent instead:
  395.  
  396.         msg[0]   = VIEW_FAILED
  397.         msg[3/4] = filename    // may be NULL and should be ignored!
  398.         msg[5]   = errcode    // see above
  399.         msg[6]   = 0
  400.         msg[7]   = wid
  401.  
  402.     If the viewer has not the possibility to store the 
  403.     application's ap_id, he /may/ not inform the apllication, if 
  404.     the window wasn't closed as a reaction to a application's 
  405.     message.
  406.     ==> This is much easier to implement but may lead to 
  407.     unexpected results. Please tell me your experiences!
  408.  
  409.  
  410. 6. The messages'IDs
  411. ===================
  412.  
  413. At least the defines for the messages' ids:
  414.  
  415. #define VIEW_FILE    0x5600
  416. #define VIEW_FAILED  0x5601
  417. #define VIEW_OPEN    0x5602
  418. #define VIEW_CLOSED  0x5603
  419.  
  420. #define VIEWERR_ERROR 0
  421. #define VIEWERR_SIZE  1
  422. #define VIEWERR_COLOR 2
  423. #define VIEWERR_WID   3
  424.  
  425. // 0x56xx - 'V' as in 'View' !!!
  426.  
  427. All other message-ids from 0x5600 to 0x56FF are reserved for 
  428. future extensions of the 'View'-protocol!
  429.  
  430.                 
  431.